#include<bits/stdc++.h>
using namespace std;
const int N=100009;
int n,r[N],rr1,rr2,js[N],l[N],ans,gj[N],sm[N];
int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>r[i];
        if(r[i]==1)rr1++;
        if(r[i]==2)rr2++;
    }
    if(rr1+rr2==n){
        if(rr1>rr2){
            cout<<rr1;
            return 0;
        }
        if(rr1==rr2){
            cout<<rr2;
            return 0;
        }
        if(rr2>rr1){
            cout<<rr2;
            return 0;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<i;j++){
            if(r[j]<r[i]&&gj[i]==0&&sm[j]==0){
                sm[j]=1;
                gj[i]=1;
            }
        }
    }
    for(int i=1;i<=n;i++){
        if(sm[i]==0)ans++;
    }
    cout<<ans;
    return 0;
}
